/**
 * Project Name:九色鹿
 * File Name:SmsEnumType.java
 * Package Name:com.fxp.project.jiuselu.sms.enums
 * Date:2020年04月01日 22:56
 * Copyright (c) 2020, Jason.Wang All Rights Reserved.
 */
package com.fxp.project.jiuselu.sms.enums;

import com.fxp.project.jiuselu.commons.constant.ConstantCode;
import com.fxp.project.jiuselu.commons.exceptions.JiuLuException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * EnumName:SmsEnumType<br/>
 * Function: 定义类型<br/>
 * Date:2020年04月01日 22:56<br/>
 *
 * @author Jason.Wang
 * @version 1.0.0.0
 * @see
 * @since JDK1.8
 */
@Getter
@AllArgsConstructor
public enum SmsEnumType {

    VERIFICATION(1, "验证码类型短信", "verificationSmsService"),
    NOTIFICATION(2, "通知类型短信", "notificationSmsService");


    /**
     * 前端传递的键 1 验证码短信 2 通知短信
     */
    private Integer key;
    /**
     * 我们需要显示的名称
     */
    private String name;
    /**
     * 对应的service实现类key
     */
    private String service;

    /**
     * getEnumByType: 根据当前的key获取对象<br/>
     *
     * @param key
     * @return
     * @author Jason.Wang
     * @createTime 2020/4/1 23:02
     */
    public static SmsEnumType getEnumByType(Integer key) {
        for (SmsEnumType item : SmsEnumType.values()) {
            if (item.getKey().equals(key)) {
                return item;
            }
        }
        throw new JiuLuException(ConstantCode.SYSTEM_EXCEPTION.getCode(), "通过key获取枚举类异常");
    }
}
